﻿using System;
using System.Diagnostics.Contracts;
using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class Feat11FdaAutoFilter
    {
        private BiffAutoFilter recAutoFilter = new BiffAutoFilter();
     //   private uint cbAutoFilter;
        private ushort unused = 0xffff;


        public Feat11FdaAutoFilter(BinaryReader reader)
        {
            var cbAutoFilter = reader.ReadUInt32();
            Contract.Assert(cbAutoFilter <= 2080);
            this.unused = reader.ReadUInt16();
            this.recAutoFilter = new BiffAutoFilter();
            this.recAutoFilter.Read(reader, cbAutoFilter);
        }

        public Feat11FdaAutoFilter()
        {
        }

        public void Write(BinaryWriter writer)
        {
            uint cbAutoFilter = (uint) recAutoFilter.Length;
            Contract.Assert(cbAutoFilter <= 2080);
            writer.Write(cbAutoFilter);
            writer.Write(unused);
            this.recAutoFilter.Write(writer);
        }
    }
}